#include "AdminUser.h"
#include "AdminHostRight.h"
#include "AdminConfiguration.h"

AgoraAdmin::User::User(const unsigned id, const std::string& login, const std::string& password)
: _id(id), _login(login), _password(password)/*, _currentChannel(NULL)*/, _currentChannelRight(NULL)
{
	_hostRight = new HostRight(); //get _hostRight par defaut
	_connected = false;
	_idCurrentChannel = 0;
}

AgoraAdmin::User::~User(void)
{
}

const unsigned int	AgoraAdmin::User::GetId() const
{
	return this->_id;
}

const std::string&	AgoraAdmin::User::GetLogin() const
{
	return this->_login;
}

void				AgoraAdmin::User::SetLogin(const std::string& login)
{
	//changement dans la base
	Configuration::GetConfiguration()->GetDatabase()->UpdateUserLogin(this->_id, login);
	this->_login = login;
}

const std::string&	AgoraAdmin::User::GetPassword() const
{
	return this->_password;
}

void				AgoraAdmin::User::SetPassword(const std::string& password)
{
	//changement dans la base
	Configuration::GetConfiguration()->GetDatabase()->UpdateUserPassword(this->_id, password);
	this->_password = password;
}

//AgoraAdmin::IChannel*		AgoraAdmin::User::GetCurrentChannel() const
//{
//	return this->_currentChannel;
//}
//
//void				AgoraAdmin::User::SetCurrentChannel(IChannel* channel)
//{
//	this->_currentChannel = channel;
//}

AgoraAdmin::IHostRight*	AgoraAdmin::User::GetHostRight() const
{
	return this->_hostRight;
}

void				AgoraAdmin::User::SetNoCurrentChannel(void)
{
	/*this->_currentChannel = NULL;
	if (this->_currentChannelRight)
		delete this->_currentChannelRight;
	this->_currentChannelRight = NULL;*/
	this->SetCurrentChannelId(0);
}

unsigned int		AgoraAdmin::User::GetCurrentChannelId() const
{
	return this->_idCurrentChannel;
}

void				AgoraAdmin::User::SetCurrentChannelId(unsigned int id)
{
	this->_idCurrentChannel = id;
}

bool				AgoraAdmin::User::IsConnected() const
{
	return this->_connected;
}

void				AgoraAdmin::User::SetConnected(const bool value)
{
	this->_connected = value;
}
